import { Button } from "tdesign-react";
import { connect } from "react-redux";
import { setLanguage } from "@/redux/modules/global/action";
import { TranslateIcon } from "tdesign-icons-react";

const Chooselanguage = (props: any) => {
	const { language, setLanguage } = props;
	const handleLanguage = () => {
		language === "zh" ? setLanguage("en") : setLanguage("zh");
	};

	return (
		<Button variant="text" onClick={handleLanguage}>
			<TranslateIcon />
		</Button>
	);
};

const mapStateToProps = (state: any) => state.global;
const mapDispatchToProps = { setLanguage };
export default connect(mapStateToProps, mapDispatchToProps)(Chooselanguage);
